package com.beauty.dressing.module.main.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.beauty.dressing.R;
import com.beauty.dressing.common.bean.SearchHotBean;
import com.framework.common.base.IBaseAdapter;


/**
 * @author lying
 * @company 9zhitx.com
 */
public class HotAdapter extends IBaseAdapter<SearchHotBean> {

    public HotAdapter(Context context){
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView=mInflater.inflate(R.layout.search_hot_item, null);
            holder = new ViewHolder();
            holder.numTxt=(TextView) convertView.findViewById(R.id.search_num_txt);
            holder.title=(TextView) convertView.findViewById(R.id.search_hot_item_txt);
            convertView.setTag(holder);
        }else{
            holder=(ViewHolder) convertView.getTag();
        }
        holder.title.setText(mList.get(position).name);

        setNumTxt(holder.numTxt,position);
        setTitleColor(holder.title,position);
        return convertView;
    }
    
    private void setNumTxt(TextView textView, int position){
    	int color = 0;
    	switch (position) {
		case 0:
			color = mContext.getResources().getColor(R.color.main_color);
			break;
		case 1:
			color = mContext.getResources().getColor(R.color.color_FD9316);
			break;
		case 2:
			color = mContext.getResources().getColor(R.color.color_F8CA2B);
			break;
		default:
			color = mContext.getResources().getColor(R.color.color_999999);
			break;
		}

		textView.setTextColor(color);
        textView.setText(String.valueOf(position+1));

    }

    private void setTitleColor(TextView textView, int position){
        int color = 0;
        switch (position) {
            case 0:
            case 1:
            case 2:
                color = mContext.getResources().getColor(R.color.color_666666);
                break;
            default:
                color = mContext.getResources().getColor(R.color.color_999999);
                break;
        }

        textView.setTextColor(color);
    }

    class ViewHolder{
        TextView numTxt;
        TextView title;
    }
}
